package pack0910;

// switch-case
public class DemoL {

    // 案例：给常见手机号设置快捷呼叫
    // 1：爸爸 2：妈妈 3：爷爷 4：奶奶
    public static void a() {
        int number = (int) (Math.random() * 4 + 1);
        if (number == 1) {
            System.out.println("打电话给爸爸");
        } else if (number == 2) {
            System.out.println("打电话给妈妈");
        } else if (number == 3) {
            System.out.println("打电话给爷爷");
        } else if (number == 4) {
            System.out.println("打电话给奶奶");
        } else {
            System.out.println("打错了");
        }
        System.out.println("-----------------------------");
        switch (number) {
            case 1: // number==1
                System.out.println("打电话给爸爸");
                break;
            case 2: // number==1
                System.out.println("打电话给妈妈");
                break;
            case 3: // number==1
                System.out.println("打电话给爷爷");
                break;
            case 4: // number==1
                System.out.println("打电话给奶奶");
                break;
            default:
                System.out.println("打错了");
        }
    }

    // ❌
    public static void b() {
        double a = 1.9;
        // char、byte、short、int、String和枚举
        /*switch (a){

        }*/
    }

    // ❌
    public static void c() {
        /*String a = "a";
        switch (a){
            // case 不能重复
            case "a": //  a=="a"
                ///
                break;
            case "a":   // a=="a"
                break;
        }*/
    }

    // ❌ 逻辑
    public static void d() {
        int number = (int) (Math.random() * 4 + 1);
        switch (number) {
            case 1: // number==1
                System.out.println("打电话给爸爸");
            case 2: // number==1
                System.out.println("打电话给妈妈");
            case 3: // number==1
                System.out.println("打电话给爷爷");
            case 4: // number==1
                System.out.println("打电话给奶奶");
            default:
                System.out.println("打错了");
        }
    }

    // 目前流行
    public static void e() {
        int number = (int) (Math.random() * 4 + 1);
        switch (number) {
            case 1 -> System.out.println("打电话给爸爸");
            case 2 -> System.out.println("打电话给妈妈");
            case 3 -> System.out.println("打电话给爷爷");
            case 4 -> System.out.println("打电话给奶奶");
            default -> System.out.println("打错了");
        }
    }

    public static void main(String[] args) {
        e();
    }
}
